import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SArenaCrossToplist } from "../../../../../Message/Public/SArenaCrossToplist";
import { PlayerUtil } from "../../common/util/PlayerUtil";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { Cache } from "../../../cache/Cache";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { EArenaOutLine } from "../../../../../Message/Public/EArenaOutLine";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class ArenaCrossTopListCellRenderer2
    
    export  class ArenaCrossTopListCellRenderer2 extends CellRenderer
    {
        constructor()
        {
            super();
            this.init();
            this.mouseChildren = true;
            return;
        }

        /* internal  */init(): void
        {
            this.initStyle();
            this.createChildren();
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */createChildren(): void
        {
            this._textFromat = new GTextFormat(FontUtil.songtiName, 12, 11661311);
            this._textFromat.align = flash.text.TextFormatAlign.CENTER;
            this._tfRank = ObjCreate.createTextField("", 0, 14, 60, 20, this, this._textFromat);
            this._tfName = ObjCreate.createTextField("", 60, 14, 180, 20, this, this._textFromat);
            this._tfPower = ObjCreate.createTextField("", 240, 14, 60, 20, this, this._textFromat);
            this._tfLevel = ObjCreate.createTextField("", 300, 14, 60, 20, this, this._textFromat);
            this._tfCareer = ObjCreate.createTextField("", 360, 14, 70, 20, this, this._textFromat);
            this._tfWin = ObjCreate.createTextField("", 430, 14, 70, 20, this, this._textFromat);
            this._tfLose = ObjCreate.createTextField("", 500, 14, 70, 20, this, this._textFromat);
            this._tfWinPer = ObjCreate.createTextField("", 570, 14, 70, 20, this, this._textFromat);
            this._tfLeftLifePer = ObjCreate.createTextField("", 640, 14, 80, 20, this, this._textFromat);
            this._btnLook = ObjCreate.createGButton(Language.getString(44279), 735, 12, 50, 22, this, "LinkButton");
            this._btnLook.addEventListener(flash.events.MouseEvent.CLICK, this.onClickLook);
            ObjCreate.createBg(5, 40, 790, 2, this, "SplitLine");
            return;
        }

        /* internal  */onClickLook(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._arenaCrossTopList) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetArenaCrossPlayerInfo, this._arenaCrossTopList.miniPlayer.entityId));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "sarenacrosstoplist") 
            {
                this._arenaCrossTopList = arg1 as SArenaCrossToplist;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            this._tfRank.text = this._arenaCrossTopList.rank.toString();
            this._tfName.text = PlayerUtil.getProxyAndName(this._arenaCrossTopList.miniPlayer);
            this._tfPower.text = this._arenaCrossTopList.miniPlayer.warfare.toString();
            this._tfLevel.text = this._arenaCrossTopList.miniPlayer.level.toString();
            this._tfCareer.text = PlayerUtil.getCareerHtml(this._arenaCrossTopList.miniPlayer.career);
            this._tfWin.text = this._arenaCrossTopList.winNum.toString();
            this._tfLose.text = this._arenaCrossTopList.loseNum.toString();
            var loc1="0";
            if (this._arenaCrossTopList.winNum + this._arenaCrossTopList.loseNum > 0) 
            {
                loc1 = (this._arenaCrossTopList.winNum * 100 / (this._arenaCrossTopList.winNum + this._arenaCrossTopList.loseNum)).toFixed(2);
            }
            this._tfWinPer.text = loc1 + "%";
            this._tfLeftLifePer.text = (this._arenaCrossTopList.lifePer * 1 / 100).toFixed(2) + "%";
            if (EntityUtil.toString(Cache.instance.role.entityInfo.entityId) != EntityUtil.toString(this._arenaCrossTopList.miniPlayer.entityId)) 
            {
                this._tfRank.textColor = 11661311;
                this._tfName.textColor = 11661311;
                this._tfPower.textColor = 11661311;
                this._tfLevel.textColor = 11661311;
                this._tfCareer.textColor = 11661311;
                this._tfWin.textColor = 11661311;
                this._tfLose.textColor = 11661311;
                this._tfWinPer.textColor = 11661311;
                this._tfLeftLifePer.textColor = 11661311;
                if (this._star && this._star.parent) 
                {
                    this._star.parent.removeChild(this._star);
                }
            }
            else 
            {
                this._tfRank.textColor = 6350622;
                this._tfName.textColor = 6350622;
                this._tfPower.textColor = 6350622;
                this._tfLevel.textColor = 6350622;
                this._tfCareer.textColor = 6350622;
                this._tfWin.textColor = 6350622;
                this._tfLose.textColor = 6350622;
                this._tfWinPer.textColor = 6350622;
                this._tfLeftLifePer.textColor = 6350622;
                if (!this._star) 
                {
                    this._star = GlobalClass.getBitmap(ImagesConst.ChatGuildMember_star);
                    this._star.x = 0;
                    this._star.y = 10;
                }
                this.addChild(this._star);
            }
            return;
        }

        /* internal  */getResultText(): string
        {
            var loc1="---";
            var loc2=this._arenaCrossTopList.outLine.value();
            switch (loc2) 
            {
                case EArenaOutLine._EArenaOutLineUnKnown:
                {
                    loc1 = "---";
                    break;
                }
                case EArenaOutLine._EArenaOutLineNo:
                {
                    loc1 = Language.getString(44201);
                    break;
                }
                case EArenaOutLine._EArenaOutLineYes:
                {
                    loc1 = Language.getString(44202);
                    break;
                }
            }
            return loc1;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal */ /* var */_star: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfRank: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfPower: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCareer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWin: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLose: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWinPer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLeftLifePer: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnLook: GButton;

        /* internal */ /* var */_textFromat: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_arenaCrossTopList: SArenaCrossToplist;
    }
